package com.udaos.modules.card.controllers;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.subject.Subject;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import com.udaos.common.base.Result;
import com.udaos.common.page.DataTableColumn;
import com.udaos.common.page.DataTableOrder;
import com.udaos.modules.card.services.UdCardReviewService;

@IocBean
@At("/platform/cardReview")
public class UdCardReviewController {

	@Inject
	private UdCardReviewService cardReviewService;
	
	/**
	 * 首页
	 */
	@At("")
	@Ok("beetl:/platform/card/review/index.html")
	public void index(){
		
	}
	
	/**
	 * 加载数据
	 * @param length
	 * @param start
	 * @param draw
	 * @param order
	 * @param columns
	 * @return
	 */
	@At
	@Ok("json:full") 
	@RequiresAuthentication
	public Object data(@Param("length") int length, @Param("start") int start,
			@Param("draw") int draw, @Param("::order") List<DataTableOrder> order,
			@Param("::columns") List<DataTableColumn> columns) {
		Subject subject = SecurityUtils.getSubject();
		if (subject != null) {
			return cardReviewService.data(length, start, draw, order, columns, null, null);
		}else{
			return Result.error("system.error");
		}
	}
}
